<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?php echo ($column); ?></title>
    <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="/yunfu/Public/Css/my.css" rel="stylesheet">

    <script src="/yunfu/Public/Js/my.js"></script>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/yunfu/Public/Js/jquery.lazyload.min.js"></script>
</head>
<body id="body">
<div class="container" id="container">
    <div class="row top">
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" align="left">
        <img src="/yunfu/Public/images/back-white.png" align="center" id="back">
    </div>
    <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8" align="center">
        <span><?php echo ($column); ?></span>
    </div>
    <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2" align="right">
        <img src="/yunfu/Public/images/home.png" align="center" id="home">
    </div>
</div>
<script>
    mBind("<?php echo U('Index/index');?>");
</script>
    <br>
    <!--topbar ends here-->

    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" align="center">
            <ul class="list-group news-list-group" style="border:none" id="news-list">
                <?php if($count == 0): ?><li style="font-size: large;margin-top: 20px;font-weight: bold;list-style: none;border: none">暂无"<?php echo ($column); ?>"的相关信息
                    </li>
                    <?php else: ?>
                    <!--news list-->
                    <?php if(is_array($news)): foreach($news as $key=>$item): ?><li class="list-group-item" align="left" onclick="newsDetail('<?php echo ($item["id"]); ?>')">
                            <div class="row  news-item">
                                <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 news-img" align="center">
                                    <img src="<?php echo ($item["homepage"]); ?>" style="max-height: 100%;max-width: 100%;">
                                </div>
                                <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8 news-body">
                                    <div class="news-title"><?php echo ($item["title"]); ?></div>
                                    <div class="news-time"><?php echo ($item["publishertime"]); ?></div>
                                    <div class="news-content">
                                        <?php echo ($item["intro"]); ?>
                                    </div>
                                </div>
                            </div>
                        </li><?php endforeach; endif; endif; ?>
            </ul>

        </div>
    </div>
    <?php if($count != 0): ?><div class="row" align="center">
            <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xs-offset-1 col-sm-offset-1 col-md-offset-1 col-lg-offset-1 load-more-bn" align="center" id="loadMore">
                加载更多
            </div>
        </div><?php endif; ?>
</div>
<!-- follows are hidden element -->
<input type="text" id="i_cid" style="visibility: hidden" value="<?php echo ($columnId); ?>">

<script type="text/javascript">
    function newsDetail(newsId) {
        window.location.href = "<?php echo U('News/detail');?>&newsId=" + newsId;
    }

    $("#loadMore").bind({
        click:function(){
            if($("#loadMore").html() == "无更多内容"){
                return;
            }
            $("#loadMore").html("加载中...");
            $.ajax({
                type: "POST",
                url: "<?php echo U('News/more');?>",
                data: {column: $("#i_cid").val()},
                dataType: "json",
                success: function (json) {
                    var status = json.status;
                    //内容已加载完了
                    if(status == 0){
                        $("#loadMore").html("无更多内容");
                        return;
                    }
                    //添加节点
                    $.each(json.news, function (index, item) {
                        //创建节点
                        var li = document.createElement("li");
                        li.setAttribute("class", "list-group-item");
                        li.setAttribute("align", "left");
                        li.setAttribute("onclick", "newsDetail('" +item.id + "')");
                        var div1 = document.createElement("div");
                        div1.setAttribute("class", "row  news-item");
                        var div11 = document.createElement("div");
                        div11.setAttribute("class", "col-xs-4 col-sm-4 col-md-4 col-lg-4 news-img");
                        div11.setAttribute("align", "center");
                        var img = document.createElement("img");
                        img.setAttribute("src", item.homepage);
                        img.setAttribute("style", "max-height: 100%;max-width: 100%;");
                        var div12 = document.createElement("div");
                        div12.setAttribute("class", "col-xs-8 col-sm-8 col-md-8 col-lg-8 news-body");
                        var div121 = document.createElement("div");
                        div121.setAttribute("class", "news-title");
                        div121.innerHTML = item.title;
                        var div122 = document.createElement("div");
                        div122.setAttribute("class", "news-time");
                        div122.innerHTML = item.publishertime;
                        var div123 = document.createElement("div");
                        div123.setAttribute("class", "news-content");
                        div123.innerHTML = item.intro;
                        //添加节点
                        div11.appendChild(img);
                        div12.appendChild(div121);
                        div12.appendChild(div122);
                        div12.appendChild(div123);
                        div1.appendChild(div11);
                        div1.appendChild(div12);
                        li.appendChild(div1);
                        document.getElementById("news-list").appendChild(li);
                    });
                    $("#loadMore").html("加载更多");
                },
                error: function (msg) {
                    $("#loadMore").html("获取数据失败,请检查网络是否可用");
                    return;
                }
            });

        },

        mousedown:function(){
            if($("#loadMore").html() == "无更多内容"){
                return;
            }
            $("#loadMore").css("background-color","#AAAAAB");
        },
        mouseup:function(){
            if($("#loadMore").html() == "无更多内容"){
                return;
            }
            $("#loadMore").css("background-color","#CCCCCC");
        }
    });

</script>
</body>
</html>